object PartialFunDemo03 {
  def main(args: Array[String]): Unit = {
    val list = List(1, 2, 3, 4, "hello")
    /**
     * 第⼀种简写⽅式：使⽤case
     * @return
     */
    def partialFun1: PartialFunction[Any, Int] = {
      case i: Int => i + 1
    }
    val res1 = list.collect(partialFun1)
    //res1 = List(2, 3, 4, 5)
    println("res1 = " + res1)
    /**
     * 第⼆种简写⽅式：
     */
    val res2 = list.collect {
      case i: Int => i + 1
    }
    // res2 = List(2, 3, 4, 5)
    println("res2 = " + res2)
  }
}